package o;

import android.net.Uri;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.upstream.DataSpec;
import java.io.IOException;
import java.util.List;
import java.util.Map;

public final class aly implements alj {
    private boolean ˋ;
    private long ˎ;
    private final ale ˏ;
    private final alj ॱ;

    public aly(alj o_alj, ale o_ale) {
        this.ॱ = (alj) amm.ॱ(o_alj);
        this.ˏ = (ale) amm.ॱ(o_ale);
    }

    public void ॱ(alx o_alx) {
        this.ॱ.ॱ(o_alx);
    }

    public long ˋ(DataSpec dataSpec) throws IOException {
        this.ˎ = this.ॱ.ˋ(dataSpec);
        if (this.ˎ == 0) {
            return 0;
        }
        if (dataSpec.ᐝ == -1 && this.ˎ != -1) {
            dataSpec = dataSpec.ॱ(0, this.ˎ);
        }
        this.ˋ = true;
        this.ˏ.ˏ(dataSpec);
        return this.ˎ;
    }

    public int ˋ(byte[] bArr, int i, int i2) throws IOException {
        if (this.ˎ == 0) {
            return -1;
        }
        int ˋ = this.ॱ.ˋ(bArr, i, i2);
        if (ˋ <= 0) {
            return ˋ;
        }
        this.ˏ.ˋ(bArr, i, ˋ);
        if (this.ˎ == -1) {
            return ˋ;
        }
        this.ˎ -= (long) ˋ;
        return ˋ;
    }

    @Nullable
    public Uri ˊ() {
        return this.ॱ.ˊ();
    }

    public Map<String, List<String>> ˎ() {
        return this.ॱ.ˎ();
    }

    public void ॱ() throws IOException {
        try {
            this.ॱ.ॱ();
        } finally {
            if (this.ˋ) {
                this.ˋ = false;
                this.ˏ.ˋ();
            }
        }
    }
}
